import java.io.BufferedReader;
import java.io.InputStreamReader;

class DivisorSumation {
	private static BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
	private static int numCases, i, j, acc, num;

	public static void main(String[] args) throws Exception {
		numCases = Integer.parseInt(br.readLine());

		for (i = 0; i < numCases; i++) {
			num = Integer.parseInt(br.readLine());
			acc = 0;
			for (j = 1; j < num; j++) {
				if (num % j == 0) {
					acc += j;
				}
			}
			System.out.print(acc + "\n");
		}

	}

}
